package ynu.edu.achitectureclass.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ynu.edu.achitectureclass.entity.Greenhouse;
import ynu.edu.achitectureclass.repository.GreenHouseRepository;

import java.util.List;
import java.util.Optional;

@Service
public class GreenHouseService {

    @Autowired
    private GreenHouseRepository greenHouseRepository;

    // 获取全部温室数据
    public List<Greenhouse> getAllGreenhouses() {
        return greenHouseRepository.findAll();
    }

    // 根据ID获取单个温室数据
    public Optional<Greenhouse> getGreenhouseById(Long id) {
        return greenHouseRepository.findById(id);
    }
}